#include "vector/tensor_test.h"

#include "log.h"
#include "vector/tensor.h"

void TensorTest::test()
{
    std::vector<std::vector<double>> a{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
    std::vector<std::vector<double>> b{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}};
    auto output = Tensor::dot(a, b);
    LogInfo() << "a: " << a;
    LogInfo() << "b: " << b;
    LogInfo() << "output: " << output;

    auto output_T = Tensor::transpose(output);
    LogInfo() << "output_T: " << output_T;

    {
        std::vector<std::vector<double>> a{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
        std::vector<std::vector<double>> b{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
        auto c= Tensor::multiply(a, b);
        LogInfo() << "a: " << a;
        LogInfo() << "b: " << b;
        LogInfo() << "multiply(a, b): " << c;
        std::cout << std::endl;
    }

    {
        std::vector<std::vector<double>> a{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
        double b = 0.1;
        auto c= Tensor::multiply(a, b);
        LogInfo() << "a: " << a;
        LogInfo() << "b: " << b;
        LogInfo() << "multiply(a, b): " << c;
        std::cout << std::endl;
    }

    {
        std::vector<double> a{1, 2, 3};
        double b = 0.1;
        auto c= Tensor::multiply(a, b);
        LogInfo() << "a: " << a;
        LogInfo() << "b: " << b;
        LogInfo() << "multiply(a, b): " << c;
        std::cout << std::endl;
    }

    {
        std::vector<std::vector<double>> a{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
        std::vector<std::vector<double>> b{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
        auto c= Tensor::minus(a, b);
        LogInfo() << "a: " << a;
        LogInfo() << "b: " << b;
        LogInfo() << "minus(a, b): " << c;
        std::cout << std::endl;
    }

    {
        std::vector<double> a{1, 2, 3};
        std::vector<double> b{10, 11, 12};
        auto c= Tensor::minus(a, b);
        LogInfo() << "a: " << a;
        LogInfo() << "b: " << b;
        LogInfo() << "minus(a, b): " << c;
        std::cout << std::endl;
    }
}